<?php

namespace common\domain\components\actions;

use common\domain\base\ApiResponse;

class CreateAction extends \yii\rest\CreateAction
{
    use ApiResponse;

    /**
     * @return  array
     * @throws \yii\web\ServerErrorHttpException
     */
    public function run(): array
    {
        $model = parent::run();
        $msg = $model->getFirstErrors();
        if (!empty($msg)) {
            return $this->responseError('输入错误', $msg);
        }

        return $this->responseSuccess($model);
    }
}
